package com.qianfeng.smartdevice.mapper;

import com.qianfeng.smartdevice.pojo.SysUserOnline;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @time: 2022-03-17 13:20
 */
public interface SysUserOnlineMapper {

    @Insert("INSERT INTO sys_user_online values (#{sessionId},#{loginName},#{ipaddr},#{loginLocation},#{browser},#{os},#{status},#{startTimestamp},#{lastAccessTime},#{expireTime})")
    void addSysUserOnline(SysUserOnline sysUserOnline);


    @Select("SELECT COUNT(*) FROM sys_user_online WHERE login_name=#{loginName} ")
    int findByUserName(String loginName);

    @Update("UPDATE sys_user_online SET sessionId=#{sessionId},ipaddr=#{ipaddr},login_location=#{loginLocation},browser=#{browser},os=#{os},status=#{status},start_timestamp=#{startTimestamp},last_access_time=#{lastAccessTime},expire_time=#{expireTime} WHERE login_name=#{loginName}")
    void updateSysUserOnline(SysUserOnline sysUserOnline);
}
